package com.sf.service.impl;

import com.sf.mapper.AmountMapper;
import com.sf.service.IAmountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
@Service
public class AmountServiceImpl implements IAmountService {
    @Autowired
    private AmountMapper amountMapper;

    @Override
    @Transactional
    public void trans(Long toId, Long fromId, BigDecimal amount) {
        //转出
        amountMapper.transDerc(fromId,amount);

       int i=1/0;

       //转入
        amountMapper.transAdd(toId,amount);
    }
}
